import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_module/channels/tabbar_channel.dart';

class HomePage extends StatefulWidget {
  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

  bool showTabBar = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          onPressed: () {

          },
          icon: Icon(Icons.arrow_back_ios_new),
        ),
        title: const Text("主页面 - Flutter页面"),
      ),
      body: Container(
        color: Colors.grey.withOpacity(0.1),
        width: double.infinity,
        height: double.infinity,
        child: Center(
          child: InkWell(
            child: Text("测试数据测试测试数据测试测试数据测试测试数据测试"),
            onTap: () {

            },
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton.extended(
        label: Text(
          "显示/隐藏 TabBar",
          style: TextStyle(
              color: Colors.black
          ),
        ),
        backgroundColor: Colors.white,
        onPressed: () {
          showTabBar = !this.showTabBar;
          if (showTabBar) {
            didPopNext();
          } else {
            didPushNext();
          }
        },
      ),
    );
  }

  void didPopNext() {
    // 5. 返回到当前页面
    TabBarController.showTab();
  }

  void didPushNext() {
    // 6. 跳转到下一个页面
    TabBarController.hideTab();
  }
}